﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<% 

%>
<div class="bg_box w_980">
	<div class="reg_box">
    	<h2>会员注册</h2>
        <ul>
        	<li class="li_bg"><label><span class="red_tip">*</span>中文名：</label><input maxlength="10" name="u_name" type="text" /><span  class="red_tip" id="spname"></span></li>
        	<li><label>英文名：</label><input type="text" maxlength="15" name="u_enName" /></li>
        	<li class="li_bg"><label><span class="red_tip">*</span>登录帐号：</label><input lflag="0" maxlength="20" name="u_nick" type="text" /><span id="spnick">字母数字组成,字母开头，4-20字符以内</span></li>
            <li class="li_bg"><label><span class="red_tip">*</span>密码：</label><input type="password" name="u_pass" /><span  class="red_tip" id="sppass"></span></li>
        	<li><label><span class="red_tip">*</span>重复密码：</label><input type="password" name="u_repass" /><span class="red_tip" id="sprepass"></span></li>
        	<li class="li_bg"><label>有效证件号：</label><input type="text" maxlength="20" style="width:270px" name="u_papers" /></li>
        	<li><label><span class="red_tip">*</span>出生日期：</label><input type="text" name="u_birthday" class="date" /><span class="red_tip" id="spbirthday"></span></li>
        	<li class="li_bg"><label><span class="red_tip">*</span>性别：</label><label class="radio_style"><input name="u_sex" type="radio" value="0" checked />男</label><label class="radio_style"><input name="u_sex" type="radio" value="1" />女</label></li>
        	<li><label><span class="red_tip">*</span>在读学校：</label><input name="u_school" maxlength="50" type="text" style="width:430px;" /><span class="red_tip" id="spschool"></span></li>
        	<li class="li_bg"><label>在读班级：</label><input maxlength="10" name="u_class" type="text" /></li>
            <li class="li_bg"><label>入学前英语基础：</label><input maxlength="100" name="u_english" type="text" /></li>
        </ul>
        <ul>
        	<li class="li_bg"><label>家长1姓名：</label><input maxlength="10" name="u_patriarchName1" type="text" /></li>
        	<li><label>家长1与学员关系：</label><input type="text" maxlength="25" name="u_raletion1" /></li>
        	<li class="li_bg"><label><span class="red_tip">*</span>联系电话1：</label><input  maxlength="20" name="u_tel1" type="text" /><span class="red_tip" id="sptel1"></span></li>
        	<li><label>家长1年龄：</label><input type="text" name="u_patriarchAge1" maxlength="3" />岁<span class="red_tip" id="sppatriarchAge1"></span></li>
        	<li class="li_bg"><label>家长1学历：</label><input type="text" maxlength="10" name="u_patriarchEducation1" /></li>
        	<li><label>家长1从事行业：</label><input type="text" name="u_job1" maxlength="20" /></li>
        	<li class="li_bg"><label>家长1职位：</label><input type="text" name="u_post1"  maxlength="10"/></li>
        </ul>
        <ul>
        	<li class="li_bg"><label>家长2姓名：</label><input maxlength="10" name="u_patriarchName2" type="text" /></li>
        	<li><label>家长2与学员关系：</label><input type="text" maxlength="25" name="u_raletion2" /></li>
        	<li class="li_bg"><label>联系电话2：</label><input name="u_tel2" maxlength="20" type="text" /></li>
        	<li><label>家长2年龄：</label><input type="text" name="u_patriarchAge2" maxlength="3" />岁<span class="red_tip" id="sppatriarchAge2"></span></li>
        	<li class="li_bg"><label>家长2学历：</label><input type="text" name="u_patriarchEducation2" maxlength="10" /></li>
        	<li><label>家长2从事行业：</label><input type="text" name="u_job2" maxlength="20" /></li>
        	<li class="li_bg"><label>家长2职位：</label><input type="text" name="u_post2" maxlength="10" /></li>
        </ul>
        <ul>
        	<li class="li_bg"><label>住址：</label><input type="text" maxlength="100" style="width:430px;" name="u_address" /></li>
        	<li><label><span class="red_tip">*</span>邮箱地址：</label><input maxlength="30" type="text" name="u_email" style="width:220px;" /><span class="red_tip" id="spemail"></span></li>
        </ul>
        <div class="reg_btn_box">
        	<a href="javascript:void(0);" id="btnReg" class=" btn_reg btn_01">注册</a>
            <a href="javascript:void(0);" id="btnReset" class="btn_rewrite btn_02">重置</a>
        </div>
    </div>
</div>
<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/Scripts/form.js" type="text/javascript"></script>
<script src="/Scripts/datepicker/js/jquery-ui-1.7.custom.min.js" type="text/javascript"></script>
<link href="/Scripts/datepicker/css/smoothness/jquery-ui-1.7.custom.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
    $(function () {
        $('.date').datepicker({
            numberOfMonths: 1,
            showButtonPanel: true,
            changeMonth: true,
            yearRange: '-40:+1', changeYear: true
        });
        $("#btnReset").click(function () {
            $("input").each(function () {
                $(this).val("");
            });
        });
        $("input[name=u_nick]").blur(function () {
            if (/^[a-zA-Z][a-zA-Z0-9]{4,20}$/.test($("input[name=u_nick]").val())) {
                $.post("/login/vreg.html", { nick: $("input[name=u_nick]").val() }, function (bdta) {
                    if (bdta == 1) {
                        $("#spnick").html("该登录名已经被注册");
                        $("#spnick").addClass("red_tip");
                        $("input[name=u_nick]").attr("lflag", "0");
                        $("input[name=u_nick]").focus();
                        $("input[name=u_nick]").select();
                    }
                    else {
                        $("#spnick").html("字母数字组成,字母开头，4-20字符以内");
                        $("#spnick").removeClass("red_tip");
                        $("input[name=u_nick]").attr("lflag", "1");
                    }
                });
            }
        });
        $("#btnReg").click(function () {
            var userinfo = { u_id: 0, u_nick: "", u_from: 1, u_registTime: new Date, u_number: "", u_name: "", u_enName: "", u_jwclass: 1, u_papers: "", u_birthday: new Date, u_age: 0, u_sex: 0, u_school: "", u_class: "", u_english: "", u_patriarchName1: "", u_raletion1: "", u_tel1: "", u_patriarchAge1: 0, u_patriarchEducation1: "", u_job1: "", u_post1: "", u_patriarchName2: "", u_raletion2: "", u_tel2: "", u_patriarchAge2: 0, u_patriarchEducation2: "", u_job2: "", u_post2: "", u_address: "", u_email: "", u_state: 3, u_time: null, u_teacher1: "", u_teacher2: "", u_studyTime1: "", u_studyTime2: "", u_vip: 0 };
            var flag = true;
            if ($("input[name=u_name]").val().replace(/\s+/g, "") == "") {
                $("#spname").html("中文名不能为空");
                flag = false;
            }
            else {
                $("#spname").html("");
            }

            if ($("input[name=u_nick]").val().replace(/\s+/g, "") == "") {
                $("#spnick").html("登录帐号不能为空");
                $("#spnick").addClass("red_tip");
                flag = false;
            }
            else {
                if (!/^[a-zA-Z][a-zA-Z0-9]{4,20}$/.test($("input[name=u_nick]").val())) {
                    $("#spnick").html("格式不正确,字母数字组成,字母开头，4-20字符以内");
                    $("#spnick").addClass("red_tip");
                    flag = false;
                } else {
                    $("#spnick").html("字母数字组成,字母开头，4-20字符以内");
                    $("#spnick").removeClass("red_tip");
                }
            }
            if ($("input[name=u_pass]").val().replace(/\s+/g, "") == "") {
                $("#sppass").html("密码不能为空");
                flag = false;
            }
            else {
                $("#sppass").html("");
            }
            if ($("input[name=u_repass]").val().replace(/\s+/g, "") == "") {
                $("#sprepass").html("重复密码不能为空");
                flag = false;
            }
            else {
                $("#sprepass").html("");
            }
            if ($("input[name=u_birthday]").val().replace(/\s+/g, "") == "") {
                $("#spbirthday").html("出生日期不能为空");
                flag = false;
            }
            else {
                $("#spbirthday").html("");
            }
            if ($("input[name=u_school]").val().replace(/\s+/g, "") == "") {
                $("#spschool").html("在读学校不能为空");
                flag = false;
            }
            else {
                $("#spschool").html("");
            }
            if ($("input[name=u_tel1]").val().replace(/\s+/g, "") == "") {
                $("#sptel1").html("联系电话1不能为空");
                flag = false;
            }
            else {
                $("#sptel1").html("");
            }
            if ($("input[name=u_email]").val().replace(/\s+/g, "") == "") {
                $("#spemail").html("电子邮箱不能为空");
                flag = false;
            }
            else {
                if (!/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test($("input[name=u_email]").val())) {
                    $("#spemail").html("电子邮箱格式不正确");
                    flag = false;
                } else {
                    $("#spemail").html("");
                }
            }
            if ($("input[name=u_patriarchAge1]").val().replace(/\s+/g, "") != "") {
                if (!/^\d{0,3}$/.test($("input[name=u_patriarchAge1]").val())) {
                    $("#sppatriarchAge1").html("家长1年龄格式不正确");
                    flag = false;
                }
                else {
                    $("#sppatriarchAge1").html("");
                }
            }
            else {
                $("#sppatriarchAge1").html("");
            }
            if ($("input[name=u_patriarchAge2]").val().replace(/\s+/g, "") != "") {
                if (!/^\d{0,3}$/.test($("input[name=u_patriarchAge2]").val())) {
                    $("#sppatriarchAge2").html("家长2年龄格式不正确");
                    flag = false;
                }
                else {
                    $("#sppatriarchAge2").html("");
                }
            }
            else {
                $("#sppatriarchAge2").html("");
            }
            if (!flag) {
                return false;
            }
            if ($("input[name=u_pass]").val() != $("input[name=u_repass]").val()) {
                $("#sppass").html("两次密码输入不一致，请重新输入");
                return false;
            }
            else {
                $("#sppass").html("");
            }
            if ($("input[name=u_nick]").attr("lflag") == "0") {
                $("#spnick").html("该登录帐号已经注册，请换一个");
                $("input[name=u_nick]").focus();
                $("input[name=u_nick]").select();
                return false;
            }
            userinfo.u_name = $("input[name=u_name]").val();
            userinfo.u_enName = $("input[name=u_enName]").val();
            userinfo.u_nick = $("input[name=u_nick]").val();
            userinfo.u_pass = $("input[name=u_pass]").val();
            userinfo.u_papers = $("input[name=u_papers]").val();
            userinfo.u_birthday = $("input[name=u_birthday]").val();
            userinfo.u_sex = $("input:[name=u_sex]:radio:checked").val();
            userinfo.u_school = $("input[name=u_school]").val();
            userinfo.u_class = $("input[name=u_class]").val();
            userinfo.u_english = $("input[name=u_english]").val();
            userinfo.u_patriarchName1 = $("input[name=u_patriarchName1]").val();
            userinfo.u_raletion1 = $("input[name=u_raletion1]").val();
            userinfo.u_tel1 = $("input[name=u_tel1]").val();
            userinfo.u_patriarchAge1 = $("input[name=u_patriarchAge1]").val();
            userinfo.u_patriarchEducation1 = $("input[name=u_patriarchEducation1]").val();
            userinfo.u_job1 = $("input[name=u_job1]").val();
            userinfo.u_post1 = $("input[name=u_post1]").val();
            userinfo.u_patriarchName2 = $("input[name=u_patriarchName2]").val();
            userinfo.u_raletion2 = $("input[name=u_raletion2]").val();
            userinfo.u_tel2 = $("input[name=u_tel2]").val();
            userinfo.u_patriarchAge2 = $("input[name=u_patriarchAge2]").val();
            userinfo.u_patriarchEducation2 = $("input[name=u_patriarchEducation2]").val();
            userinfo.u_job2 = $("input[name=u_job2]").val();
            userinfo.u_post2 = $("input[name=u_post2]").val();
            userinfo.u_address = $("input[name=u_address]").val();
            userinfo.u_email = $("input[name=u_email]").val();

            $.post("/login/saveUserInfo.html", { userinfo: $.toJSON(userinfo) }, function (dta) {
                alert("注册成功");
                $("#btnReset").click();
            });
        });
    });

</script>

</asp:Content>
